﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class UserControls_jiaodiantu : System.Web.UI.UserControl
{
    private static DataClassesDataContext da = new DataClassesDataContext();
    private static int f = 1;
    protected void Page_Load(object sender, EventArgs e)
    {
        Image1.ImageUrl = "~/" + da.StoredProcedure3(1).FirstOrDefault().iconurl.ToString();
        Image2.ImageUrl = "~/" + da.StoredProcedure3(2).FirstOrDefault().iconurl.ToString();
        Image3.ImageUrl = "~/" + da.StoredProcedure3(3).FirstOrDefault().iconurl.ToString();
        Image4.ImageUrl = "~/" + da.StoredProcedure3(4).FirstOrDefault().iconurl.ToString();
        Image5.ImageUrl = "~/" + da.StoredProcedure3(5).FirstOrDefault().iconurl.ToString();

        //   fint(ref f);
        string myScript = @"function SubmitKeyClick(va) {";
        foreach (frontimg v in da.frontimg)
        {
            myScript += "  if (va == " + v.id.ToString() + "){document.getElementById('mydiv').style.background ='url(" + v.picurl + ")';}";

        }
        myScript += "}";
        //    string myScript2 = @"alert(document.getElementById('mydiv').style.background);";
        //  myScript+="if (va == 1){document.getElementById('MainContent_Imagea').src  = 'ProductImages/d46ac7361e18e8094d7aac0f4e1d0380.jpg'}}";
        Page.ClientScript.RegisterStartupScript(Page.GetType(), "key1", myScript, true);
        // Page.ClientScript.RegisterStartupScript(Page.GetType(), "key1", myScript2, true);
        //    ImageButton1.Attributes.Add("OnMouseOver", "javascript:SubmitKeyClick()");
        Image1.Attributes["OnMouseOver"] = "javascript:SubmitKeyClick(1);this.className='border1'";
        Image1.Attributes["onmouseout"] = "javascript:this.className='newStyle1'";
        Image2.Attributes["OnMouseOver"] = "javascript:SubmitKeyClick(2);this.className='border1'";
        Image2.Attributes["onmouseout"] = "javascript:this.className='newStyle1'";
        Image3.Attributes["OnMouseOver"] = "javascript:SubmitKeyClick(3);this.className='border1'";
        Image3.Attributes["onmouseout"] = "javascript:this.className='newStyle1'";
        Image4.Attributes["OnMouseOver"] = "javascript:SubmitKeyClick(4);this.className='border1'";
        Image4.Attributes["onmouseout"] = "javascript:this.className='newStyle1'";
        Image5.Attributes["OnMouseOver"] = "javascript:SubmitKeyClick(5);this.className='border1'"; //   Label1.Text = "fdssdf1";
        Image4.Attributes["onmouseout"] = "javascript:this.className='newStyle1'";
    }
   
    public void Button1_Click(object sender, EventArgs e)
    {
        //   mydiv.Style["background-image"] = "url('ProductImages/c5b8abab87d10744729cb7877e90cfdb.jpg')"; 



    }

    public void Button2_Click(object sender, EventArgs e)
    {
        fc(ref f);
        if (f < 1)
        {
            Image1.ImageUrl = "~/" + da.StoredProcedure3(1).FirstOrDefault().iconurl.ToString();
            Image2.ImageUrl = "~/" + da.StoredProcedure3(2).FirstOrDefault().iconurl.ToString();
            Image3.ImageUrl = "~/" + da.StoredProcedure3(3).FirstOrDefault().iconurl.ToString();
            Image4.ImageUrl = "~/" + da.StoredProcedure3(4).FirstOrDefault().iconurl.ToString();
            Image5.ImageUrl = "~/" + da.StoredProcedure3(5).FirstOrDefault().iconurl.ToString();
            //    Image1.ImageUrl = "~" + da.StoredProcedure1(1).FirstOrDefault().iconurl.ToString();
            Image1.Attributes["OnMouseOver"] = "javascript:SubmitKeyClick(1);this.className='border1'";
            Image2.Attributes["OnMouseOver"] = "javascript:SubmitKeyClick(2);this.className='border1'";
            Image3.Attributes["OnMouseOver"] = "javascript:SubmitKeyClick(3);this.className='border1'";
            Image4.Attributes["OnMouseOver"] = "javascript:SubmitKeyClick(4);this.className='border1'";
            Image5.Attributes["OnMouseOver"] = "javascript:SubmitKeyClick(5);this.className='border1'";

            Image1.Attributes["onmouseout"] = "javascript:this.className='newStyle1'";
            Image2.Attributes["onmouseout"] = "javascript:this.className='newStyle1'";
            Image3.Attributes["onmouseout"] = "javascript:this.className='newStyle1'";
            Image4.Attributes["onmouseout"] = "javascript:this.className='newStyle1'";
            Image5.Attributes["onmouseout"] = "javascript:this.className='newStyle1'";
        }
        else
        {
            string myScript2 = @"SubmitKeyClick(" + f + ");";
            //   string myScript2 = @"alert(document.getElementById('mydiv').style.background);";
            Page.ClientScript.RegisterStartupScript(Page.GetType(), "key2", myScript2, true);
            //mydiv.Style["background-image"] = "url('" + da.frontimg.ToList().ElementAt(f).picurl + "')";
            Image1.ImageUrl = "~/" + da.StoredProcedure3(f).FirstOrDefault().iconurl.ToString();
            Image2.ImageUrl = "~/" + da.StoredProcedure3(f + 1).FirstOrDefault().iconurl.ToString();
            Image3.ImageUrl = "~/" + da.StoredProcedure3(f + 2).FirstOrDefault().iconurl.ToString();
            Image4.ImageUrl = "~/" + da.StoredProcedure3(f + 3).FirstOrDefault().iconurl.ToString();
            Image5.ImageUrl = "~/" + da.StoredProcedure3(f + 4).FirstOrDefault().iconurl.ToString();
            Image1.Attributes["OnMouseOver"] = "javascript:SubmitKeyClick(" + f + ");" + "this.className='border1'";
            Image2.Attributes["OnMouseOver"] = "javascript:SubmitKeyClick(" + (f + 1) + ");" + "this.className='border1'";
            Image3.Attributes["OnMouseOver"] = "javascript:SubmitKeyClick(" + (f + 2) + ")" + ";this.className='border1'";
            Image4.Attributes["OnMouseOver"] = "javascript:SubmitKeyClick(" + (f + 3) + ")" + ";this.className='border1'";
            Image5.Attributes["OnMouseOver"] = "javascript:SubmitKeyClick(" + (f + 4) + ")" + ";this.className='border1'"; // 

            Image1.Attributes["onmouseout"] = "javascript:this.className='newStyle1'";
            Image2.Attributes["onmouseout"] = "javascript:this.className='newStyle1'";
            Image3.Attributes["onmouseout"] = "javascript:this.className='newStyle1'";
            Image4.Attributes["onmouseout"] = "javascript:this.className='newStyle1'";
            Image5.Attributes["onmouseout"] = "javascript:this.className='newStyle1'";
        }


    }
    public void Button3_Click(object sender, EventArgs e)
    {
        if (f > 20)
        {
            fint(ref f);
        }
        fj(ref f);
        string myScript2 = @"SubmitKeyClick(" + f + ");";
        //   string myScript2 = @"alert(document.getElementById('mydiv').style.background);";
        Page.ClientScript.RegisterStartupScript(Page.GetType(), "key2", myScript2, true);
        //mydiv.Style["background-image"] = "url('" + da.frontimg.ToList().ElementAt(f).picurl + "')";
        Image1.ImageUrl = "~/" + da.StoredProcedure3(f).FirstOrDefault().iconurl.ToString();
        Image2.ImageUrl = "~/" + da.StoredProcedure3(f + 1).FirstOrDefault().iconurl.ToString();
        Image3.ImageUrl = "~/" + da.StoredProcedure3(f + 2).FirstOrDefault().iconurl.ToString();
        Image4.ImageUrl = "~/" + da.StoredProcedure3(f + 3).FirstOrDefault().iconurl.ToString();
        Image5.ImageUrl = "~/" + da.StoredProcedure3(f + 4).FirstOrDefault().iconurl.ToString();
        Image1.Attributes["OnMouseOver"] = "javascript:SubmitKeyClick(" + f + ")" + ";this.className='border1'";
        Image2.Attributes["OnMouseOver"] = "javascript:SubmitKeyClick(" + (f + 1) + ")" + ";this.className='border1'";
        Image3.Attributes["OnMouseOver"] = "javascript:SubmitKeyClick(" + (f + 2) + ")" + ";this.className='border1'";
        Image4.Attributes["OnMouseOver"] = "javascript:SubmitKeyClick(" + (f + 3) + ")" + ";this.className='border1'";
        Image5.Attributes["OnMouseOver"] = "javascript:SubmitKeyClick(" + (f + 4) + ")" + ";this.className='border1'"; // 

        Image1.Attributes["onmouseout"] = "javascript:this.className='newStyle1'";
        Image2.Attributes["onmouseout"] = "javascript:this.className='newStyle1'";
        Image3.Attributes["onmouseout"] = "javascript:this.className='newStyle1'";
        Image4.Attributes["onmouseout"] = "javascript:this.className='newStyle1'";
        Image5.Attributes["onmouseout"] = "javascript:this.className='newStyle1'";
    }
    public static void fint(ref int f)
    {
        f = 1;
    }
    public static void fj(ref int f)
    {
        f = f + 1;
    }
    public static void fc(ref int f)
    {
        f = f - 1;
    }
}